package com.common.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * TODO
 *
 * @Description
 * @Author tm
 * @Date 2023-09-08 11:11
 **/
public class PythonUtils {
    public static void call(String date,String dtus,String type){
        try {
            String str = "python3 /zhnl/oem-admin/python/gps_calc.py";
            if(date!=null){
                str+=" --d "+date;
            }
            if(dtus!=null){
                str+=" --c "+dtus;
            }
            if(type!=null && "pcb".equals(type)){
                str+=" --t 1";
            }
            System.out.println(")))))))))))))))))))) str : " + str);
            Process proc =  Runtime.getRuntime().exec(str);//执行脚本

            BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line = null;
            while((line = reader.readLine()) != null){
                System.out.println(line);
            }
            reader.close();
            proc.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void callLocation(String date,String dtus,String type){
        try {
            String str = "C:\\Users\\tm\\AppData\\Local\\Programs\\Python\\Python38\\python C:\\Users\\tm\\AppData\\Local\\Programs\\Python\\Python38\\project\\gps\\gps_calc.py";
            if(date!=null){
                str+=" --d "+date;
            }
            if(dtus!=null){
                str+=" --c "+dtus;
            }
            if(type!=null && "pcb".equals(type)){
                str+=" --t 1";
            }
            System.out.println(")))))))))))))))))))) str : " + str);
            Process proc =  Runtime.getRuntime().exec(str);//执行脚本

            BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line = null;
            while((line = reader.readLine()) != null){
                System.out.println(line);
            }
            reader.close();
            proc.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void callNanSha(String date,String dtus,String type){
        try {
            String str = "python C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python38\\project\\gps\\gps_calc.py";
            if(date!=null){
                str+=" --d "+date;
            }
            if(dtus!=null){
                str+=" --c "+dtus;
            }
            if(type!=null && "pcb".equals(type)){
                str+=" --t 1";
            }
            System.out.println(")))))))))))))))))))) str : " + str);
            Process proc =  Runtime.getRuntime().exec(str);//执行脚本

            BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line = null;
            while((line = reader.readLine()) != null){
                System.out.println(line);
            }
            reader.close();
            proc.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
